﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBHelper;
using BusinessLayer.WorldArtPrice.Entities;
using System.Data.SqlClient;
using System.Data;


namespace BusinessLayer.WorldArtPrice
{
    public class MarketingCategoryBL
    {
        private readonly DbHelper _db;

        public MarketingCategoryBL()
        {
            _db = new DbHelper(new DbConfig().DbWorldArtPriceConnectionString);
        }

        

        public MarketingCategory GetByCode(string code)
        {
            var oCommand = new SqlCommand(Common.Constants.StoredProcedures.GetMarketingCategoryByCode) { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@Code", code));
            var list = _db.GetList<MarketingCategory>(oCommand);
            return list.FirstOrDefault();
        }
        public MarketingCategory GetByID(int id)
        {
            var oCommand = new SqlCommand(Common.Constants.StoredProcedures.GetMarketingCategoryByID) { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@CategoryID", id));
            var list = _db.GetList<MarketingCategory>(oCommand);
            return list.FirstOrDefault();
        }
        public List<MarketingCategory> GetAll()
        {
            var oCommand = new SqlCommand(Common.Constants.StoredProcedures.GetAllMarketingCategories) { CommandType = CommandType.StoredProcedure };
            return _db.GetList<MarketingCategory>(oCommand);
            
        }
        
    }
}
